package com.macro.mall.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.UmsServiceDeptLog;
import com.macro.mall.service.UmsServiceDeptLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * UmsServiceDeptLog的路由接口服务
 * 
 * @author 
 *
 */
@RestController
@RequestMapping("serviceDeptLog")
@Api(tags = "UmsServiceDeptLogController", description = "服务机构操作日志")
public class UmsServiceDeptLogController {

	/** UmsServiceDeptLogService服务 */
	@Autowired
	private UmsServiceDeptLogService umsServiceDeptLogService;
	
	/**
	 * 查询所有UmsServiceDeptLog数据的方法
	 * @return
	 */
    @ApiOperation("查询list")
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public CommonResult find(@ApiParam(value = "机构id") @RequestParam(value = "deptId", defaultValue = "1") Integer deptId,
                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                             @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize ) {
        UmsServiceDeptLog.builder().deptId(deptId).build();
        List<UmsServiceDeptLog> umsServiceDeptLogs = umsServiceDeptLogService.find(UmsServiceDeptLog.builder().deptId(deptId).build(), pageNum, pageSize);
        return CommonResult.success(CommonPage.restPage(umsServiceDeptLogs));
	}
	
	/**
	 * 通过id查询UmsServiceDeptLog数据的方法
	 * @param id
	 * @return
	 */
    @ApiOperation("通过id 查询")
	@RequestMapping(value = "/findOneById", method = RequestMethod.GET)
	public CommonResult findOne(@RequestParam(value="id") Integer id) {
        UmsServiceDeptLog one = umsServiceDeptLogService.findOne(id);
        return CommonResult.success(one);
	}
	
	/**
	 * 插入UmsServiceDeptLog属性不为空的数据方法
	 * @param value
	 * @return
	 */
    @ApiOperation("新增")
	@RequestMapping(value = "/save", method = RequestMethod.POST)
	public CommonResult save(@RequestBody UmsServiceDeptLog value) {
		return umsServiceDeptLogService.saveNotNull(value);
	}
	
	/**
	 * 更新UmsServiceDeptLog属性不为空的数据方法
	 * @param value
	 * @return
	 */
    @ApiOperation("修改")
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public CommonResult update(@RequestBody UmsServiceDeptLog value) {
		return umsServiceDeptLogService.updateNotNullById(value);
	}

	/**
	 * 通过id删除UmsServiceDeptLog数据方法
	 * @param id
	 * @return
	 */
    @ApiOperation("删除")
	@RequestMapping(value = "/delete", method = RequestMethod.GET)
	public CommonResult delete(@RequestParam(value="id") Integer id) {
		return umsServiceDeptLogService.deleteById(id);
	}
}
